﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace WJP.ComponentModel
{
    /// <summary>
    /// 从指定的程序集路径加载插件
    /// </summary>
    public class AssemblyFileListPluginSource : PluginSourceBase
    {
        public string[] FilePaths { get; }

        public AssemblyFileListPluginSource(params string[] filePaths)
        {
            FilePaths = filePaths ?? new string[0];
        }

        /// <summary>
        /// 加载指定路径的插件
        /// </summary>
        /// <returns></returns>
        protected override List<Assembly> LoadAssemblies()
        {
            return FilePaths.Select(
                Assembly.LoadFile
            ).ToList();
        }
    }
}
